<template>
  <!-- 本周新书 -->
  <section class="week-new-book">
    <h1>
      <span>本周新书</span>
      <span>每周六晚8点半上新</span>
    </h1>
    <router-link
      class="new-book-gray"
      v-for="value of newBookList"
      :key="value.title"
      :to="/detail/ + value.pdsid"
    >
      <img :src="value.imgUrl" alt="" />
      <p>{{ value.title }}</p>
      <p>{{ value.describe }}</p>
      <p>{{ value.view }}</p>
    </router-link>
  </section>
</template>

<script>
import { onMounted, computed } from "vue";
import { useStore } from "vuex";
export default {
  setup() {
    const store = useStore();
    const getWeekNewBook = () => store.dispatch("getWeekNewBook");
    onMounted(() => getWeekNewBook());
    // 本周新书列表
    const newBookList = computed(
      () => store.state.recommend.getWeekNewBook.result
    );
    return {
      newBookList,
      getWeekNewBook,
    };
  },
};
</script>

<style lang="less" scoped>
// 本周新书
.week-new-book {
  padding: 0 12px;
  position: relative;
  height: 160px;
  margin-bottom: 25px;
  h1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 13px;
    span {
      font-family: PingFang SC;
      font-weight: bold;
      &:first-of-type {
        color: #000000;
        font-size: 18px;
      }
      &:last-of-type {
        font-size: 12px;
        color: #737373;
      }
    }
  }
  .new-book-gray {
    position: absolute;
    width: 345px;
    height: 89px;
    background-color: #f6f8f7;
    top: 66px;
    img {
      width: 85px;
      height: 114px;
      position: absolute;
      left: 9px;
      bottom: 10px;
    }
    p {
      position: absolute;
      left: 105px;
      font-family: PingFang SC;
      font-weight: bold;
      margin: 0;
      &:nth-of-type(1) {
        top: -36px;
        color: #444243;
        font-size: 17px;
      }
      &:nth-of-type(2) {
        top: 10px;
        color: #787a79;
        font-size: 14px;
      }
      &:nth-of-type(3) {
        bottom: 13px;
        color: #c9a35c;
        font-size: 12px;
      }
    }
  }
}
</style>
